﻿CREATE TABLE [dbo].[Thread](
	[Id] [bigint] IDENTITY(1,1) NOT NULL,
	[BoardId] [bigint] NOT NULL,
	[PosterId] [bigint] NOT NULL,
	[IconId] [tinyint] NOT NULL DEFAULT ((0)),
	[ReadPermission] [int] NOT NULL DEFAULT ((0)),
	[Price] [int] NOT NULL DEFAULT ((0)),
	[Poster] [nvarchar](50)  NOT NULL,
	[Title] [nvarchar](100)  NOT NULL,
	[Content] [ntext]  NOT NULL,
	[PostTime] [datetime] NOT NULL DEFAULT (getdate()),
	[LastPostTime] [datetime] NOT NULL DEFAULT (getdate()),
	[LastpostId] [bigint] NOT NULL DEFAULT ((0)),
	[LastPoster] [nvarchar](50)  NULL,
	[LastPosterId] [bigint] NOT NULL DEFAULT ((0)),
	[LastEditer] [nvarchar](50)  NULL,
	[views] [int] NOT NULL DEFAULT ((0)),
	[replies] [int] NOT NULL DEFAULT ((0)),
	[DisplayOrder] [int] NOT NULL DEFAULT ((0)),
	[TypeId] [bigint] NOT NULL DEFAULT ((0)),
	[Attachment] [bit] NULL,
	[Hide] [bit] NULL,
	[Invisible] [bit] NULL,
 CONSTRAINT [PK_Thread] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'主题id' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'Id'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'版块id' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'BoardId'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'作者id' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'PosterId'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'主题图标id' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'IconId'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'阅读权限' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'ReadPermission'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'主题出售价格积分' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'Price'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'作者' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'Poster'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'标题' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'Title'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'内容' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'Content'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'发布时间' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'PostTime'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最后回复时间' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'LastPostTime'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最后回复帖子ID' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'LastpostId'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最后回复用户名' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'LastPoster'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'最后回复用户名ID' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'LastPosterId'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'查看数' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'views'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'回复数' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'replies'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'>0为置顶,<0不显示,==0正常 -1为回收站 -2待审核' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'DisplayOrder'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'主题类型id' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'TypeId'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否含有附件' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'Attachment'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否为回复可见帖' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'Hide'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'是否隐藏, 如果未通过审核则为隐藏' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread', @level2type=N'COLUMN', @level2name=N'Invisible'

GO
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'主题表' ,@level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'Thread'

